//
//  UIAlertViewViewController.m
//  DemoAlertView
//
//  Created by tangkexiong on 16/3/8.
//  Copyright © 2016年 tangkexiong. All rights reserved.
//

#import "UIAlertViewViewController.h"

@interface UIAlertViewViewController ()<UIAlertViewDelegate>

@end

@implementation UIAlertViewViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(8, 72, 100, 100)];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [btn setTitle:@"对话框" forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    
    [self btnClicked:nil];

    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)btnClicked:(id)sender {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"无", nil];
    alert.title = @"测试\n测试\n测试\n测试\n";
    alert.message = @"测试\n测试\n测试\n测试";
    alert.delegate = self;
    //    alert.alertViewStyle = UIAlertViewStylePlainTextInput;
    alert.tintColor = [UIColor redColor];
    [alert addButtonWithTitle:@"忽略"];
    [alert addButtonWithTitle:@"确定"];
    [alert addButtonWithTitle:@"确定"];
    [alert addButtonWithTitle:@"确定"];
    [alert addButtonWithTitle:@"确定"];
    [alert addButtonWithTitle:@"确定"];
    [alert show];
}

#pragma mark - UIAlertViewDelegate

- (void)alertViewCancel:(UIAlertView *)alertView {
    NSLog(@"%s", __FUNCTION__);
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    UIWindow *window = alertView.window;
    NSLog(@"%@", window);
    NSLog(@"%s, %d", __FUNCTION__, (int)buttonIndex);
}

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
    NSLog(@"%s, %d", __FUNCTION__, (int)buttonIndex);
}

- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex {
    NSLog(@"%s, %d", __FUNCTION__, (int)buttonIndex);
}

- (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView {
    return NO;
}

- (void)willPresentAlertView:(UIAlertView *)alertView {
    NSLog(@"%s", __FUNCTION__);
}

- (void)didPresentAlertView:(UIAlertView *)alertView {
    NSLog(@"%s", __FUNCTION__);
}

@end
